package xcmg.device.web.vehicle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xcmg.device.infra.BasicController;
import xcmg.device.infra.ErrorCode;
import xcmg.device.service.vehicle.VehicleService;
import xcmg.device.service.vo.warehouse.WarehouseDeliveryVO;
import yb.ecp.fast.infra.annotation.FastMappingInfo;
import yb.ecp.fast.infra.infra.ActionResult;
import yb.ecp.fast.infra.infra.PageCommonVO;
import yb.ecp.fast.infra.infra.SearchCommonVO;

@RestController
@RequestMapping("/vehicle")
public class VehicleController extends BasicController {

    @Autowired
    private VehicleService vehicleService;

    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult list(@RequestBody SearchCommonVO<WarehouseDeliveryVO> condition)throws Exception{
        WarehouseDeliveryVO deliveryVO = condition.getFilters();
        deliveryVO.setOrgId(getOrgId());
        condition.setFilters(deliveryVO);
        PageCommonVO pageCommonVO = vehicleService.list(condition);
        return actionValueResult(pageCommonVO.getPageInfo());
    }

    @RequestMapping(value = "/listDetial",method = RequestMethod.POST)
    @FastMappingInfo(needLogin = true)
    public ActionResult item(@RequestBody SearchCommonVO<WarehouseDeliveryVO> condition)throws Exception{
        WarehouseDeliveryVO deliveryVO = condition.getFilters();
        deliveryVO.setOrgId(getOrgId());
        condition.setFilters(deliveryVO);
        return actionResult(ErrorCode.Success, vehicleService.listDetial(condition));
    }
}
